#include <stdio.h>

int do_strange_things (const int x) // unsigned
{
	int even = 0, odd = 0;
	int i = 0;
	int ret = 0; // result

	for ( ; i < 32 ; ++i) {
		if (i & x>>i & 01) // i is odd AND x has bit in 'i' position
			++odd;
		else if (i % 2 == 0 && (x>>i) & 01)
			++even;
	}

	for (i = 0 ; i < even ; ++i)
		ret |= 1 << (i * 2);

	for (i = 0 ; i < odd ; ++i)
		ret |= 1 << (i * 2 +1);

	return ret;
}


int main ()
{
	int x; // unsigned

	freopen("strange.in", "r", stdin);
	freopen("strange.out", "w", stdout);

	scanf("%d", &x);
	printf("%d\n", do_strange_things(x));
	return 0;
}
